package com.service.impl;

import com.dao.BookDao;
import com.po.Book;
import com.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookDao bookDao;

    public List<Book> findAll() {
        List<Book> books = bookDao.findAll();
        //int i = 10 / 0;
        return books;
    }

    public Book findById(Integer id) {
        Book book = bookDao.findById(id);
        return book;
    }

    public boolean save(Book book) {
        Integer boo = bookDao.save(book);
        return boo > 0;
    }

    public boolean update(Book book) {
        Integer update = bookDao.update(book);
        return update > 0;
    }

    public boolean delete(Integer id) {
        Integer delete = bookDao.delete(id);
        return delete > 0;
    }
}
